import waftools


def build(bld):
    sources = bld.path.ant_glob('**/*.c')

    def build_libutil(target, env):
        # Build the libutil directory using firmware environment
        bld.stlib(source=sources,
                  target=target,
                  includes=['.', 'includes'],
                  use='pblibc_includes',
                  env=env.derive())

    bld(export_includes=['includes'], name='libutil_includes')

    if (bld.variant not in ('test', 'test_rocky_emx')):
        build_libutil('libutil-cm0', bld.all_envs['cortex-m0'])

    build_libutil('libutil', bld.env)
    build_libutil('libutil-local', bld.all_envs['local'])


# vim:filetype=python
